package com.example.administrator.myapplication;

import android.util.Log;

import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by hp on 2017/3/29.
 * 解析json数据
 */

public class JsonParse {


    public static JsonParse sonParse;

    public static List<Table> getListTable(String list) throws Exception{
        List<Table> mlists = new ArrayList<Table>();
        //byte[] data = readParse(url);
        JSONArray array = new JSONArray(list);

        for (int i = 0; i < array.length(); i++) {
            JSONObject item = array.getJSONObject(i);
            Log.i("kun11", String.valueOf(item));
            String address = item.getString("address");
            String className = item.getString("className");
            String classNum = item.getString("classNum");
            String classType = item.getString("classType");
            String cname = item.getString("cname");
            String ctime = item.getString("ctime");
            String school_year = item.getString("school_year");
            String spid = item.getString("spid");
            String studentNum = item.getString("studentNum");
            String teachType = item.getString("teachType");

            mlists.add(new Table(address, className, classNum,classType,cname,ctime,school_year,spid,studentNum,teachType));
        }

        return mlists;
    }
}
